
<!-- <template>

    <p>登录页</p>
    <p>默认账号:admin， 默认密码:123456</p>
        <div>
        账号：<input type="text" v-model="account" placeholder="请输入你的账号">
        </div>
        <div>
        密码：<input type="password" v-model="password" placeholder="请输入你的密码">
        </div>
        <button @click="login"> 登录</button>
      
    </template>
    
    
    <script>
    export default{
        data(){
            return{
                account :'',
                password:'',
            }
        },
        methods:{
            login(){
                if(this.account ==='abc'&& this.password ==='123'){
                    alert("登录成功")
                }else{
                    alert("账号或密码错误，请重新输入")
                    // this.account = ''
                    this.password = ''
                }
                
            }
        }
        
        }
    </script> -->
    <template>
        <p>登录页</p>
        <div>
            账号: <input type="text" v-model="account" placeholder="请输入你的账号" />
        </div>
        <div>
            密码: <input type="password" v-model="password" placeholder="请输入你的账号" />
        </div>
        <div>
            <button @click="login">登录</button>
        </div>
    </template>
    
    
    <script>
    export default {
        data(){
            return {
                account:'',
                password:''
            }
        },
        methods:{
            login(){
                if(this.account === 'admin' && this.password === '123456'){
                    alert('登录成功')
                    const usrInfo = {
                        name:'张三',
                        phone:'13122223333',
                        gender:'男'
                    }
                    this.$store.commit('updateUserInfo', usrInfo)
                    this.$router.push({path:'/user'})
                } else {
                    alert('账号密码错误，请重新输入')
                }
            }
        },
    }
    
    </script>